<?php
class ResultObject
{
    public $domainID;
    public $subDomainID;
    public $orgID;
    public $searchText;
    public $yearStart;
    public $yearEnd;
    public $appID = "AppID=ef05e706-247f-44f7-9315-87ce9ae099ac";
    public $masUrl = "http://academic.research.microsoft.com/json.svc/search?";
    public $endIdx;
    public $startIdx, $resultType, $pubContent, $orderBy, $authorID;
    protected $json;
    
    public function makeQuery() {
        $query = $this->masUrl . $this->appID . "&ResultObject=" . $this->resultType;
        
        if (!is_null($this->domainID)) 
        {
            $query .= "&DomainID=" . $this->domainID;
        }
        
          if (!is_null($this->subDomainID)) 
        {
            $query .= "&SubDomainID=" . $this->subDomainID;
        }
        
          if (!is_null($this->orgID)) 
        {
            $query .= "&OrganizationID=" . $this->orgID;
        }
        
          if (!is_null($this->authorID)) 
        {
            $query .= "&AuthorID=" . $this->authorID;
        }
        
          if (!is_null($this->searchText)) 
        {
            $query .= "&FullTextQuery=" . $this->searchText;
        }
        
        if (!is_null($this->pubContent))
        {
            $query .= "&PublicationContent=" . $this->pubContent;
        }
            
        if (!is_null($this->yearStart)) 
        {
            $query .= "&YearStart=" . $this->yearStart;
        }
          
        if (!is_null($this->yearEnd)) 
        {
            $query .= "&YearEnd=" . $this->yearEnd;
        }
        
          if (!is_null($this->startIdx)) 
        {
            $query .= "&StartIdx=" . $this->startIdx;
        }
        else 
        {
            $query .= "&StartIdx=1";
        }
        
          if (!is_null($this->endIdx)) 
        {
            $query .= "&EndIdx=" . $this->endIdx;
        }
        else 
        {
            $query .= "&EndIdx=1"; 
        }
        
          if (!is_null($this->orderBy)) 
          {
              $query .= "&OrderBy=" . $this->orderBy;
          }
        
        if ($response = file_get_contents($query)) {
        
        $this->json = json_decode($response);
        }
        else {
            $this->json = "0";
        }
    }
    

   
}
?>